package com.bigflexlib.utils
{
	import com.bigflexlib.core.dependency.DependencySpec;
	import com.bigflexlib.core.dependency.EventDispatcherWithDependenciesBase;

	public class Fallback extends EventDispatcherWithDependenciesBase
	{
		
		private var valuesSpec:DependencySpec = new DependencySpec("values","*");
		[Bindable("valuesChanged")]
		public function get values():*{return dh.g( valuesSpec );}
		public function set values(v:*):void{dh.s( valuesSpec, v );}
		
		private var valueSpec:DependencySpec = new DependencySpec("value","*");
		[Bindable("valueChanged")]
		public function get value():*{return dh.g( valueSpec );}
		private function setValue(v:*):void{dh.s( valueSpec, v );}
		
		
		override protected function dependenciesUpdated() : void{
			if ( !dh.modifications[valuesSpec] )
				return;
			if ( values is Array )
			{
				var arr:Array = values as Array;
				for each ( var v:* in arr )
				{
					if ( v != undefined && v != null )
					{
						setValue( v );
						break;	
					}
				}
			}
		}				
	}
}